package cn.com.bluemoon.daps.api.notice;

import cn.com.bluemoon.daps.api.notice.factory.RemoteNoticeHandlerServiceFactory;
import cn.com.bluemoon.daps.common.constant.ServiceNameConstants.DapsApiNotice;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.notice.core.NoticeQueryVo;
import cn.com.bluemoon.daps.notice.core.NoticeType;
import cn.com.bluemoon.daps.notice.core.PreSendMsgInfo;
import cn.com.bluemoon.daps.notice.template.*;
import cn.com.bluemoon.daps.notice.template.base.BaseMessage;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author Jarod.Kong
 * @date 2020/12/22 8:28
 */
@FeignClient(value = DapsApiNotice.SERVICE, fallbackFactory = RemoteNoticeHandlerServiceFactory.class)
@RequestMapping(DapsApiNotice.BASE_URI + DapsApiNotice.API_NOTICE)
@ApiIgnore
public interface RemoteNoticeHandlerService {

    /**
     *
     * @param msgRecordId 消息记录id{@link DapSendMailRecord#getId}
     * @return 返回记录的发送内容
     */
    @GetMapping("/noticeInfo")
    ResultBean<NoticeQueryVo> queryNoticeContentById(@RequestParam("msgRecordId") String msgRecordId);

    @PostMapping("/presend")
    ResultBean<String> preSendInfo(@RequestParam(value = "type", required = false) NoticeType type,
                                           @RequestBody PreMetadataImpactTxtMessage baseMsg);

    /**
     * 接收第三方的消息-元数据表结构变化影响分析
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息，目前自带有以下： （不满足可以自定义基于{@link BaseMessage}+freemarker模板到对应目录
     * @see DevSyncMessage
     * @see ProSyncMessage
     * @see ApplyPublishMessage
     * @see MetadataImpactMessage
     */
    @PostMapping("sendMim")
    ResultBean<Boolean> sendMim(@RequestParam(value = "type", required = false) NoticeType type,
                                @RequestBody MetadataImpactMessage baseMsg);

    /**
     * 接收第三方的消息-开发同步
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息，目前自带有以下： （不满足可以自定义基于{@link BaseMessage}+freemarker模板到对应目录
     * @see DevSyncMessage
     * @see ProSyncMessage
     * @see ApplyPublishMessage
     */
    @PostMapping("sendDs")
    public ResultBean<Boolean> sendDevMsg(@RequestParam(value = "type", required = false) NoticeType type,
                                          @RequestBody DevSyncMessage baseMsg);

    /**
     * 接收第三方的消息-生产同步
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息，目前自带有以下： （不满足可以自定义基于{@link BaseMessage}+freemarker模板到对应目录
     * @see DevSyncMessage
     * @see ProSyncMessage
     * @see ApplyPublishMessage
     */
    @PostMapping("sendPs")
    public ResultBean<Boolean> sendProMsg(@RequestParam(value = "type", required = false) NoticeType type,
                                          @RequestBody ProSyncMessage baseMsg);

    /**
     * 接收第三方的消息-申请发布同步
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息，目前自带有以下： （不满足可以自定义基于{@link BaseMessage}+freemarker模板到对应目录
     * @see DevSyncMessage
     * @see ProSyncMessage
     * @see ApplyPublishMessage
     */
    @PostMapping("sendAp")
    public ResultBean<Boolean> sendApplyMsg(@RequestParam(value = "type", required = false) NoticeType type,
                                            @RequestBody ApplyPublishMessage baseMsg);




    /**
     * 接收第三方的消息-数据安全查询申请表权限
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息
     */
    @PostMapping("security/auth")
    public ResultBean<Boolean> sendSecurityApplyAuth(@RequestParam(value = "type", required = false) NoticeType type,
                                                     @RequestBody SecurityTableApplyMessage baseMsg);


    /**
     * 接收第三方的消息-数据安全查询导出申请
     *
     * @param type    消息类型，目前支持{@link NoticeType#EMAIL}
     * @param baseMsg 基础消息
     */
    @PostMapping("security/export")
    public ResultBean<Boolean> sendSecurityApplyExport(@RequestParam(value = "type", required = false) NoticeType type,
                                                       @RequestBody SecurityExportApplyMessage baseMsg);
}
